#include "controlwidget.h"

#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>

ControlWidget::ControlWidget(int reader_timeout, int writer_timeout, QWidget *parent)
    : QWidget(parent)
    , m_reader(new QSlider(Qt::Horizontal))
    , m_writer(new QSlider(Qt::Horizontal))
{
    m_reader->setMaximum(10);
    m_writer->setMaximum(10);
    m_reader->setMinimum(1);
    m_writer->setMinimum(1);
    m_reader->setValue(reader_timeout);
    m_writer->setValue(writer_timeout);

    QVBoxLayout *main = new QVBoxLayout;

    QLabel *reader_label = new QLabel("reader timeout");
    QHBoxLayout *reader_layout = new QHBoxLayout;
    reader_layout->addWidget(reader_label);
    reader_layout->addWidget(m_reader);

    QLabel *writer_label = new QLabel("writer timeout");
    QHBoxLayout *writer_layout = new QHBoxLayout;
    writer_layout->addWidget(writer_label);
    writer_layout->addWidget(m_writer);

    main->addLayout(reader_layout);
    main->addLayout(writer_layout);
    setLayout(main);

    connect(m_reader, SIGNAL(valueChanged(int)), this, SIGNAL(reader_timeout(int)));
    connect(m_writer, SIGNAL(valueChanged(int)), this, SIGNAL(writer_timeout(int)));
}
